package com.funtl.apache.dubbo.consumer.controller;

import com.funtl.apache.dubbo.provider.api.EchoService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RefreshScope
@RestController
public class EchoController {
    @Reference(version = "1.0.0")
    private EchoService echoService;

    @Value("${server.port}")
    private String port;

    @Value("${name}")
    private String name;

    @RequestMapping("/dubbo/consumer/{str}")
    public String echo(@PathVariable("str") String str){
        return echoService.echo(str);
    }

    @RequestMapping("/dubbo/showport")
    public String showPort(){
        return "我的端口号是:"+port;
    }

//@RefreshScope 动态刷新配置

    @RequestMapping("/dubbo/name")
    public String showname(){
        return "动态修改配置---name:"+name;
    }
}
